﻿<UserControl x:Class="SoftSource.Timecard.Views.UserProjectEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
             xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
             xmlns:softsourceConverters="clr-namespace:SoftSource.Common.Converters;assembly=SoftSource.Common.Silverlight">

    <UserControl.Resources>
        <softsourceConverters:ObjectToBoolConverter x:Key="ObjectToBoolConverter" />
        <softsourceConverters:MoneyConverter x:Key="MoneyConverter" />
    </UserControl.Resources>

    <controlsToolkit:BusyIndicator x:Name="Busy"
                                   HorizontalContentAlignment="Stretch"
                                   VerticalContentAlignment="Stretch">
        <Grid x:Name="LayoutRoot">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"
                                  MinWidth="200" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*"
                                  MinWidth="200" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <Grid Grid.Row="0"
                  Grid.Column="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock HorizontalAlignment="Left"
                           Text="Users:"
                           TextWrapping="Wrap"
                           Margin="4,4,0,4" />
                <data:DataGrid x:Name="SourceProjectsDataGrid"
                               AutoGenerateColumns="False"
                               ItemsSource="{Binding SourceProjects}"
                               Grid.Row="1">
                    <data:DataGrid.Columns>
                        <data:DataGridTextColumn CanUserSort="True"
                                                 Header="Project Name"
                                                 SortMemberPath="Name"
                                                 Binding="{Binding Name}" />
                    </data:DataGrid.Columns>
                </data:DataGrid>
            </Grid>

            <Grid Grid.Row="0"
                  Grid.Column="1">
                <Grid VerticalAlignment="Center"
                      HorizontalAlignment="Center">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Button Grid.Row="0"
                            FontSize="20"
                            Click="RemoveFromProject_Click"
                            Height="30"
                            Margin="4"
                            Style="{StaticResource ArrowButtonStyle}"
                            Width="50"
                            RenderTransformOrigin="0.5,0.5">
                        <Button.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform ScaleX="-1" />
                                <SkewTransform AngleX="0"
                                               AngleY="0" />
                                <RotateTransform Angle="0" />
                                <TranslateTransform />
                            </TransformGroup>
                        </Button.RenderTransform>
                    </Button>
                    <Button Grid.Row="1"
                            FontSize="20"
                            Click="AddToProject_Click"
                            Height="30"
                            Margin="4"
                            Style="{StaticResource ArrowButtonStyle}"
                            Width="50"
                            RenderTransformOrigin="0.5,0.5" />
                </Grid>
            </Grid>

            <Grid Grid.Row="0"
                  Grid.Column="2">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition />
                </Grid.RowDefinitions>
                <TextBlock HorizontalAlignment="Left"
                           Text="Project Users:"
                           TextWrapping="Wrap"
                           Margin="4,4,0,4" />
                <data:DataGrid x:Name="UserProjectsDataGrid"
                               AutoGenerateColumns="False"
                               ItemsSource="{Binding UserProjects}"
                               Grid.Row="1">
                    <data:DataGrid.Columns>
                        <data:DataGridTextColumn CanUserSort="True"
                                                 Header="Project Name"
                                                 Binding="{Binding Name}" />
                    </data:DataGrid.Columns>
                </data:DataGrid>
            </Grid>

            <Grid Grid.Row="1"
                  Grid.Column="0"
                  Grid.ColumnSpan="3"
                  Margin="0,4,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Button Content="Close"
                        Click="Close_Click"
                        Margin="0,0,4,0" />
                <Button Content="Edit membership"
                        Click="EditMembership_Click"
                        Margin="4,0,0,0"
                        Grid.Column="1"
                        IsEnabled="{Binding SelectedItem, ElementName=UserProjectsDataGrid, Mode=OneWay, Converter={StaticResource ObjectToBoolConverter}}" />
            </Grid>
        </Grid>
    </controlsToolkit:BusyIndicator>
</UserControl>